import java.util.Scanner;

public class Test {
    //前缀和
    public static int[] getSum(int[] a) {
        int[] sum = new int[a.length];
        sum[0] = a[0];
        for (int i = 1; i < a.length; i++) {
            sum[i] = sum[i - 1] + a[i];
        }
        return sum;
    }
    public static void main1(String[] args) {
        int[] a = {1, 2, 3, 4, 5};
        int[] sum = getSum(a);
        for (int j : sum) {
            System.out.println(j);
        }
    }

    public static void main(String[] args) {
        //读入数据
        Scanner in=new Scanner(System.in);
        int n=in.nextInt(),q=in.nextInt();// 3   2  （数组大小为3，每次输入两组求和数）
        int[] arr=new int[n+1];
        for (int i = 1; i <= n; i++) {
            arr[i]=in.nextInt();//  1   2   4  （当前数组）
        }

        //处理前缀和数组
        long[] dp=new long[n+1];
        for (int i = 1; i <= n; i++) {
            //两组要求和的范围
            //1  2
            //2  3
            dp[i]=dp[i-1]+arr[i];
        }

        //使用前缀和数组
        while(q>0){
            int left=in.nextInt(),right=in.nextInt();
            System.out.println(dp[right]-dp[left-1]);
            q--;
        }
    }
}
